﻿using Microsoft.Win32;

namespace Vision.VHelper
{
    public static class FileDialogHelper
    {
        /// <summary>
        /// 获取参数保存路径
        /// </summary>
        /// <returns></returns>
        public static string GetSaveFilePath()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter = @"XML Files(*.xml)|*.xml",
                RestoreDirectory = true
            };

            bool? result = saveFileDialog.ShowDialog();
            if (result == true)
            {
                return saveFileDialog.FileName;
            }
            return null;
        }

        /// <summary>
        /// 获取参数配置路径
        /// </summary>
        /// <returns></returns>
        public static string GetOpenFilePath()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = @"XML Files(*.xml)|*.xml",
                RestoreDirectory = true
            };

            bool? result = openFileDialog.ShowDialog();
            if (result == true)
            {
                return openFileDialog.FileName;
            }
            return null;
        }

        /// <summary>
        /// 获取高精度匹配模型保存路径
        /// </summary>
        /// <returns></returns>
        public static string GetSaveHPFeaturePatchFilePath()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter = @"XML Files(*.hpmxml)|*.hpmxml",
                RestoreDirectory = true
            };

            bool? result = saveFileDialog.ShowDialog();
            if (result == true)
            {
                return saveFileDialog.FileName;
            }
            return null;
        }

        /// <summary>
        /// 获取高精度匹配模型配置路径
        /// </summary>
        /// <returns></returns>
        public static string GetOpenHPFeaturePatchFilePath()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = @"XML Files(*.hpmxml)|*.hpmxml",
                RestoreDirectory = true
            };

            bool? result = openFileDialog.ShowDialog();
            if (result == true)
            {
                return openFileDialog.FileName;
            }
            return null;
        }
    }
}
